CC=g++
CFLAGS=-std=c++0x

OPATH=Obj
DIR=WS
BIN=Bin

IFACE_TEST=$(DIR)/ws.client.h $(DIR)/ws.packer.h $(DIR)/ws.request.h $(DIR)/ws.unpacker.h $(DIR)/ws.functions.h
APPS_TEST=$(DIR)/ws.client.cpp $(DIR)/ws.data.cpp $(DIR)/ws.packer.cpp $(DIR)/ws.unpacker.cpp $(DIR)/ws.request.cpp $(DIR)/ws.rpc_clnt.c $(DIR)/ws.rpc_xdr.c
TEST=$(DIR)/test.cpp

IFACE_SVC=$(DIR)/ws.assembler.h $(DIR)/ws.client.h $(DIR)/ws.functions.h $(DIR)/ws.packer.h $(DIR)/ws.request.h $(DIR)/ws.rpc.h $(DIR)/ws.token.h $(DIR)/ws.unpacker.h $(DIR)/ws.server.h
APPS_SVC=$(DIR)/ws.assembler.cpp $(DIR)/ws.data.cpp $(DIR)/ws.packer.cpp $(DIR)/ws.request.cpp $(DIR)/ws.rpc_xdr.c $(DIR)/ws.rpc_svc.cpp $(DIR)/ws.token.cpp $(DIR)/ws.unpacker.cpp $(DIR)/ws.server.cpp
SVC=$(DIR)/ws.rpc_svc.c

LIBS=Obj/utf8.o Obj/log.o Obj/authr.o Obj/nsr.o Obj/config.o Obj/ns-client*.o Obj/ar-client*.o

all: client server

client:
	$(CC) $(CFLAGS) -c $(DIR)/ws.client.cpp   -o $(OPATH)/ws-client.o
	$(CC) $(CFLAGS) -c $(DIR)/ws.data.cpp     -o $(OPATH)/ws-client-data.o
	$(CC) $(CFLAGS) -c $(DIR)/ws.packer.cpp   -o $(OPATH)/ws-client-packer.o
	$(CC) $(CFLAGS) -c $(DIR)/ws.request.cpp  -o $(OPATH)/ws-client-request.o
	$(CC) $(CFLAGS) -c $(DIR)/ws.rpc_clnt.c   -o $(OPATH)/ws-client-rpc.o
	$(CC) $(CFLAGS) -c $(DIR)/ws.rpc_xdr.c    -o $(OPATH)/ws-client-xdr.o
	$(CC) $(CFLAGS) -c $(DIR)/ws.unpacker.cpp -o $(OPATH)/ws-client-unpacker.o

server: $(IFACE_SVC) $(APPS_SVC)
	$(CC) $(CFLAGS) $(LIBS) $(APPS_SVC) $(SVC) -o $(BIN)/ws-server

test: $(IFACE_TEST) $(APPS_TEST)
	$(CC) $(CFLAGS) $(LIBS) $(APPS_TEST) $(TEST) -o $(BIN)/ws-test
